<template>
	<view class="editor">
		<!-- editorConfigs 是后端编辑器的配置
		editorConfigsJSON 是前端json文件配置
		onLoadE 是路由传来的参数
		draftDID 是草稿DID
		这四个缺一不可 -->
		<template v-if="editorConfigs&&editorConfigsJSON&&onLoadE&&draftDID">
			<!-- 标题 先判断后端编辑器是否开启了标题，然后判断前端传参是否隐藏了标题 -->
			<view
				class="title-box"
				v-if="editorConfigs.editor.title.status && !onLoadE.title">
				<input
					type="text"
					:placeholder="$t('pleaseEnterTheTitle')"
					placeholder-style="color:#C0C4CC;"
					:maxlength="editorConfigs.editor.title.length"
					v-model="title"/>
				<text :style="editorConfigs.editor.title.required?'color: #F56C6C;':''">{{editorConfigs.editor.title.required?$t('required'):$t('optional')}}</text>
				<text>{{title.length}}/{{editorConfigs.editor.title.length}}</text>
			</view>
			<!-- 评论专用，评论谁 -->
			<view class="comment-post-box" v-if="commentPost">
				<view class="comment-post-box-left">评论：</view>
				<view class="comment-post-box-right">
					{{commentPost.title?commentPost.title:$_filterHtml(commentPost.content)}}
				</view>
			</view>
			<!-- 主要内容框子 -->
			<view class="content-box">
				<!-- 内容输入框 -->
				<textarea
					:placeholder="$t('pleaseEnter')+'...'"
					placeholder-style="color:#C0C4CC;"
					:maxlength="editorConfigs.editor.contentLength"
					auto-height
					show-confirm-bar="{{false}}"
					:style="'min-height:'+onLoadE.height+'rpx;'"
					v-model="content"
					:focus="focus"
					:adjust-position="true"
					@focus="textareaFocus"
					@blur="textareaBlur"
					@linechange="textareaLinechange"
					@input="textareaInput"></textarea>

				<!-- 匿名、评论设置、字数统计 -->
				<view class="content-box-other">
					<view class="content-box-other-left">
						<template v-if="onLoadE.type !== 'comment'">
							<view
								@click="isAnonymous = !isAnonymous"
								v-if="editorConfigs.editor.anonymous && !onLoadE.anonymousbox">
								<text>{{isAnonymous?'匿名':'不匿名'}}</text>
								<text class="iconfont icon-arrow-down"></text>
							</view>
							<view
								@click="clickCommentPolicyButton"
								v-if="!onLoadE.commentbox">
								<text>
									<template v-if="commentPolicy == 1">所有人</template>
									<template v-if="commentPolicy == 2">你关注的人</template>
									<template v-if="commentPolicy == 3">你关注的人和已认证的人</template>
									<template v-if="commentPolicy == 4">不允许所有人</template>
									<template v-if="commentPolicy == 5">仅限你提及到的用户</template>
								</text>
								<text class="iconfont icon-arrow-down"></text>
							</view>
						</template>
					</view>
					<view class="content-box-other-right">
						<text>{{content.length}}/{{editorConfigs.editor.contentLength}}</text>
					</view>
				</view>
			</view>
			<view class="operating-button-other">
				<view
					style="margin-right:25rpx;"
					v-if="editorConfigs.editor.group.status"
					@click="clickGroupButton">
					<text class="iconfont icon-modular"></text>
					<text>{{groupName}}</text>
					<text v-if="groupName === $t('group')">[{{editorConfigs.editor.group.required?$t('required'):$t('optional')}}]</text>
				</view>
				<view
					v-if="editorConfigs.editor.location.status"
					@click="cliclLocationInfoButton">
					<text class="iconfont icon-dingwei"></text>
					<text>{{locationInfo.name}}</text>
				</view>
			</view>
			<view
				v-if="editorConfigs.editor.hashtag.status"
				class="operating-button-hashtag">
				<view class="_text">
					<text>{{$t('editorHashtag')}}</text>
					<text class="iconfont icon-arrow-right-filling"></text>
				</view>
				<scroll-view scroll-x>
					<view
						class="operating-button-hashtag-for"
						v-for="item in editorConfigsJSON.hashtag">
						<view @click="clickInsertHashtagButton(item)">{{item}}</view>
					</view>
				</scroll-view>
			</view>
			<view class="editor-tool-button">
				<!-- 表情 -->
				<view
					@click="emojiStatus = !emojiStatus"
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.sticker">
					<text class="iconfont icon-smile"></text>
				</view>
				<!-- 图片 -->
				<view
					@click="clickImageButton"
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.image.status">
					<text class="iconfont icon-tupian"></text>
				</view>
				<!-- 音频 -->
				<!-- #ifndef H5 -->
				<view
					@click="audioBoxStatus = !audioBoxStatus"
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.audio.status">
					<text class="iconfont icon-yuyin"></text>
				</view>
				<!-- #endif -->
				<!-- 视频 -->
				<view
					@click="clickVideoButton"
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.video.status">
					<text class="iconfont icon-zhibo"></text>
				</view>
				<!-- 艾特 -->
				<view
					@click="clickMentionBoxButton"
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.mention.status">
					<text class="iconfont icon-aite1"></text>
				</view>
				<!-- 话题 -->
				<view
					class="editor-tool-button-for"
					v-if="editorConfigs.editor.hashtag.status"
					@click="clickInsertHashtagButton_2">
					<text class="iconfont icon-huati"></text>
				</view>
				<!-- 引用 -->
				<view
					v-if="onLoadE.type == 'post'"
					class="editor-tool-button-for"
					@click="clickQuoteBoxStatusButton">
					<text class="iconfont icon-yinyong1"></text>
				</view>
				<!-- 回复可见 -->
				<view
					v-if="onLoadE.type == 'post' && editorConfigsJSON.youranHidePost"
					class="editor-tool-button-for"
					@click="clickHidePostButton">
					<text class="iconfont icon-eye-close"></text>
				</view>
				<!-- 更多 -->
				<view
					v-if="onLoadE.type == 'post' && editorConfigsJSON.editorToolButton"
					class="editor-tool-button-for"
					@click="clickMoreButton">
					<text class="iconfont icon-add-circle"></text>
				</view>
			</view>
			<!-- 引用帖子 -->
			<view class="quote-post" v-if="quotePid">
				<text class="iconfont icon-yinyong1"></text>
				<text style="padding: 0 10rpx;display: -webkit-box;-webkit-box-orient: vertical;-webkit-line-clamp: 1;overflow: hidden;" @click="$_to('post/detail?pid=' + quotePid)">{{quoteContent?quoteContent:'有引用帖子'}}</text>
				<text class="iconfont icon-close-bold" @click="quotePid = ''"></text>
			</view>
			<view class="editor-file" v-if="fileList">
				<!-- 图片附件 -->
				<template v-if="fileList.images.length">
					<view
						v-for="(item,index) in fileList.images"
						@click="$_picturePreview(index,fileList.images)"
						class="editor-file-for">
						<text
							class="iconfont icon-close-bold"
							@click.stop="clickFileButton(item.fid)"></text>
						<view class="editor-file-for-content">
							<image :src="item.imageRatioUrl" mode="widthFix"></image>
						</view>
						<text
							v-if="onLoadE.type !== 'comment'"
							class="editor-file-for-text"
							@click.stop="clickInsertFileButton(item.fid)">{{$t('insertIntoMainText')}}</text>
					</view>
				</template>
				<!-- 视频附件 -->
				<template v-if="fileList.videos.length">
					<view
						v-for="(item,index) in fileList.videos"
						@click="$_to('pages/video?url=' + encodeURIComponent(item.videoUrl))"
						class="editor-file-for">
						<text
							class="iconfont icon-close-bold"
							@click.stop="clickFileButton(item.fid)"></text>
						<view class="editor-file-for-content">
							<text class="iconfont icon-play"></text>
						</view>
						<text
							v-if="onLoadE.type !== 'comment'"
							class="editor-file-for-text"
							@click.stop="clickInsertFileButton(item.fid)">{{$t('insertIntoMainText')}}</text>
					</view>
				</template>
				<!-- 音频附件 -->
				<template v-if="fileList.audios.length">
					<view
						class="editor-file-for-audio"
						v-for="item in fileList.audios">
						<global-audio
							Css="width:642rpx;border-radius: 10rpx 0 0 10rpx;"
							:Url="item.audioUrl"></global-audio>
							<!-- <text
								v-if="onLoadE.type !== 'comment'"
								class="editor-file-for-text"
								@click="clickInsertFileButton(item.fid)">{{$t('insertIntoMainText')}}</text> -->
						<text
							class="iconfont icon-close-bold"
							@click="clickFileButton(item.fid)"></text>
					</view>
				</template>
			</view>
			<view class="publish-draft-button">
				<view
					:style="onLoadE.type === 'comment'?'background: #409EFF;border-radius: 10rpx;':'background: #409EFF;'"
					@click="cliclSubmitButton">{{$t('submit')}}</view>
				<view
					style="background: #F56C6C;"
					v-if="onLoadE.type !== 'comment'"
					@click="cliclSaveButton">{{$t('save')}}</view>
			</view>
		</template>
		<template v-else>
			<view style="width: 100%;height: 90vh;display: flex;align-items: center;justify-content: center;">
				<global-loading></global-loading>
			</view>
		</template>
		<!-- 小组选择 -->
		<view v-if="groupBoxStatus" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="groupBoxStatus = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('group')}}</text>
					<view @click="groupBoxStatus = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-groyp">
					<template v-if="groupList.length">
						<scroll-view scroll-y>
							<!-- 一层小组 -->
							<template v-for="item in groupList">
								<view class="editor-right-group-list">
									<view
										:class="item.publishRule.canPublish&&item.publishRule.allowPost?'_for _pointer':'_for'"
										@click="item.publishRule.canPublish&&item.publishRule.allowPost?clickSelectGroupButton(item.gid,item.name):''">
										<text :class="item.gid==groupGid?'_symbol _symbol-h':'_symbol'"></text>
										<text
											:style="item.publishRule.canPublish&&item.publishRule.allowPost?'':'color: #C0C4CC;'"
											:class="item.gid==groupGid?'_name-h':''">{{item.name}}</text>
									</view>
									<!-- 二层小组 -->
									<template v-for="g1 in item.groups">
										<view
											:class="g1.publishRule.canPublish&&g1.publishRule.allowPost?'_for _pointer':'_for'"
											@click="g1.publishRule.canPublish&&g1.publishRule.allowPost?clickSelectGroupButton(g1.gid,g1.name):''"
											style="padding-left: 75rpx;">
											<text :class="g1.gid==groupGid?'_symbol _symbol-h':'_symbol'"></text>
											<text
												:style="g1.publishRule.canPublish&&g1.publishRule.allowPost?'':'color: #C0C4CC;'"
												:class="g1.gid==groupGid?'_name-h':''">{{g1.name}}</text>
										</view>
										<!-- 三层小组 -->
										<template v-for="g2 in g1.groups">
											<view
												:class="g2.publishRule.canPublish&&g2.publishRule.allowPost?'_for _pointer':'_for'"
												style="padding-left: 125rpx;"
												@click="g2.publishRule.canPublish&&g2.publishRule.allowPost?clickSelectGroupButton(g2.gid,g2.name):''">
												<text :class="g2.gid==groupGid?'_symbol _symbol-h':'_symbol'"></text>
												<text
													:style="g2.publishRule.canPublish&&g2.publishRule.allowPost?'':'color: #C0C4CC;'"
													:class="g2.gid==groupGid?'_name-h':''">{{g2.name}}</text>
											</view>
											<!-- 四层小组 -->
											<template v-for="g3 in g2.groups">
												<view
													:class="g3.publishRule.canPublish&&g3.publishRule.allowPost?'_for _pointer':'_for'"
													style="padding-left: 175rpx;"
													@click="g3.publishRule.canPublish&&g3.publishRule.allowPost?clickSelectGroupButton(g3.gid,g3.name):''">
													<text :class="g3.gid==groupGid?'_symbol _symbol-h':'_symbol'"></text>
													<text
														:style="g3.publishRule.canPublish&&g3.publishRule.allowPost?'':'color: #C0C4CC;'"
														:class="g3.gid==groupGid?'_name-h':''">{{g3.name}}</text>
												</view>
											</template>
										</template>
									</template>
								</view>
							</template>
						</scroll-view>
					</template>
					<template v-else>
						<view style="width: 100%;display: flex;align-items: center;justify-content: center;padding: 100rpx 0;">
							<global-loading></global-loading>
						</view>
					</template>
				</view>
			</view>
		</view>
		<!-- 选择表情 -->
		<view v-if="emojiStatus" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="emojiStatus = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('editorStickers')}}</text>
					<view @click="emojiStatus = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="select-emoji-box">
					<view class="_box-left">
						<scroll-view scroll-y>
							<view @click="clickSwitchEmojiButton('emoji','')"
								:class="emojiHover == 'emoji'?'_hover':''">
								Emoji
							</view>
							<view
								@click="clickSwitchEmojiButton(item.code,item)"
								:class="emojiHover == item.code?'_hover':''"
								v-for="item in emojiCategories">
								{{item.name}}
							</view>
						</scroll-view>
					</view>
					<view class="_box-right">
						<scroll-view scroll-y>
							<view class="_emoji">
								<template v-if="emojiHover == 'emoji'">
									<view
										@click="clickEmojiButton(item)"
										v-for="item in editorConfigsJSON.emoji"
										class="_emoji-for">
										<text>{{item}}</text>
									</view>
								</template>
								<template v-else>
									<view
										@click="clickEmojiButton(item.codeFormat)"
										v-for="item in emojiNativeList"
										class="_emoji-for">
										<view>
											<global-lazy-load-image height="65rpx" :image="item.image"
												:imgMode='"widthFix"'></global-lazy-load-image>
										</view>
									</view>
								</template>
							</view>
						</scroll-view>
					</view>
				</view>
			</view>
		</view>
		<!-- 音频录制 -->
		<!-- #ifndef H5 -->
		<view v-if="audioBoxStatus" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="audioBoxStatus = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('audio')}}</text>
					<view @click="audioBoxStatus = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-audio">
					<view class="global-bottom-to-top-pop-up-audio-box">
						<view class="_duration">
							<text>{{audioDuration}}</text>
							<text>s</text>
						</view>
						<view class="_audio-button" @click="clickAudioButton">
							{{audioButtonText}}
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- #endif -->
		<!-- 艾特他人 -->
		<view v-if="mentionStatus" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="mentionStatus = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">{{$t('editorMention')}}</text>
					<view @click="mentionStatus = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-aite">
					<view class="global-bottom-to-top-pop-up-aite-left">
						<scroll-view scroll-y>
							<view
								:class="mentionListHover=='RecommendUser'?'_hover':''"
								@click="clickMentionTabButton('RecommendUser')">推荐用户</view>
							<view
								:class="mentionListHover=='myFollowers'?'_hover':''"
								@click="clickMentionTabButton('myFollowers')">我关注的</view>
							<template v-for="item in mentionUserRolesList">
								<view
									:class="mentionListHover==item.rid?'_hover':''"
									@click="clickMentionTabButton(item.rid)"
									v-if="item.rid !== 'interdiction' && item.rid !== 'pendingreview'">{{item.name}}</view>
							</template>
						</scroll-view>
					</view>
					<view class="global-bottom-to-top-pop-up-aite-right">
						<scroll-view scroll-y>
							<!-- 推荐用户 -->
							<template v-if="mentionListHover == 'RecommendUser'">
								<view
									v-for="item in editorConfigsJSON.RecommendUser"
									@click="clickMentionUserButton(item.username)"
									class="_user-for">
									<view class="_user-for-avatar">
										<image :src="item.avatar" mode="widthFix"></image>
									</view>
									<view class="_user-for-nickname">
										{{item.nickname}}
									</view>
									<view class="_user-for-roleName">
										{{item.roleName}}
									</view>
									<view class="_user-for-aite">
										@TA
									</view>
								</view>
							</template>
							<template v-else-if="mentionListHover == 'myFollowers'">
								<view
									v-for="item in mentionUserList"
									@click="clickMentionUserButton(item.username)"
									class="_user-for">
									<view class="_user-for-avatar">
										<image :src="item.avatar" mode="widthFix"></image>
									</view>
									<view class="_user-for-nickname">
										{{item.nickname}}
									</view>
									<view class="_user-for-roleName">
										{{item.roleName}}
									</view>
									<view class="_user-for-aite">
										@TA
									</view>
								</view>
								<view class="_user-for-more" @click="clickMentionUserListMore('myFollowers')">
									{{mentionUserListPageText}}
								</view>
							</template>
							<template v-else>
								<view
									v-for="item in mentionUserList"
									@click="clickMentionUserButton(item.username)"
									class="_user-for">
									<view class="_user-for-avatar">
										<image :src="item.avatar" mode="widthFix"></image>
									</view>
									<view class="_user-for-nickname">
										{{item.nickname}}
									</view>
									<view class="_user-for-roleName">
										{{item.roleName}}
									</view>
									<view class="_user-for-aite">
										@TA
									</view>
								</view>
								<view class="_user-for-more" @click="clickMentionUserListMore(mentionListHover)">
									{{mentionUserListPageText}}
								</view>
							</template>
						</scroll-view>
					</view>
				</view>
			</view>
		</view>
		<!-- 引用帖子 -->
		<view v-if="quoteBoxStatus" class="global-bottom-to-top-pop-up">
			<view class="_top" @click="quoteBoxStatus = false"></view>
			<view class="_bottom">
				<view class="_title">
					<text class="_title-text">引用我关注的帖子</text>
					<view @click="quoteBoxStatus = false"><text class="iconfont icon-close-bold"></text></view>
				</view>
				<view class="global-bottom-to-top-pop-up-quote-post">
					<scroll-view scroll-y>
						<template v-if="quoteListStatus === 'success'">
							<view
								class="_quote-post-for"
								v-for="item in quoteList"
								@click="clickSelectQuotePostButton(item)">
								<view class="_quote-post-for-avatar">
									<image :src="item.author.avatar" mode="widthFix"></image>
								</view>
								<view class="_quote-post-for-right">
									<view class="_quote-post-for-right-top">
										<text>{{item.author.nickname}}</text>
										<text>发表于{{item.createdTimeAgo}}</text>
									</view>
									<view class="_quote-post-for-right-bottom">
										<text>{{item.title?item.title:$_filterHtml(item.content)}}</text>
									</view>
								</view>
							</view>
							<view
								class="_quote-post-for-more"
								@click="clickQuotePostMoreButton">
								{{quoteListPageText}}
							</view>
						</template>
						<template v-if="quoteListStatus === 'loading'">
							<global-loading></global-loading>
						</template>
						<template v-if="quoteListStatus === 'empty'">
							<view class="global-bottom-to-top-pop-up-quote-post-empty">
								您还没有收藏任何帖子哟
							</view>
						</template>
					</scroll-view>
				</view>
			</view>
		</view>
		<!-- 软键盘高度 -->
		<view :style="'width: 100%;height:'+onKeyboardHeightChange+'px;'"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				onLoadE:null,//路由传来的参数
				editorConfigs:null,//编辑器配置信息
				editorConfigsJSON:null,//编辑器配置信息.前端
				
				title:"",//标题
				content:"",//内容
				contentCursorStart:"",//内容光标 起始 位置
				contentCursorEnd:"",//内容光标 结束 位置
				draftDID:"",//草稿DID
				
				focus:false,//获取焦点
				
				quotePid:"",//帖子专用: 引用的帖子 PID
				quoteList:"",
				quoteListStatus:"loading",
				quoteListPage:2,
				quoteListPageText: this.$t('clickToLoadMore'),
				quoteContent:"",//帖子专用: 引用的帖子内容
				quoteBoxStatus:false,//引用帖子的窗口
				
				groupGid:"",//小组gid
				groupName:this.$t('group'),//小组名称
				groupBoxStatus:false,//小组选择弹窗状态
				groupList:[],//小组树排列
				
				isMarkdown:true,//内容是否为 MD 格式
				isAnonymous:false,//是否匿名
				commentPolicy:1,//帖子专用: 谁可以评论
				
				fileFID:"",//附件FID
				fileList:null,//附件列表

				// 位置信息
				locationInfo:{
					langTag: "",
					name: this.$t('editorLocation'),
					mapId: 4,
					latitude: "",
					longitude: ""
				},
				
				emojiStatus: false, //--------表情弹窗
				emojiHover: "emoji", //-------当前表情分类
				emojiCategories: [], //-------原生表情分类
				emojiNativeList: [], //-------原生表情列表
				
				audioBoxStatus:false,//音频弹窗状态
				audioDuration:0,//录音秒数
				audioButtonText: "单击开始录制音频",
				audioStartStatus:false,//录音状态
				
				mentionStatus:false,//艾特框子状态
				mentionListHover:"RecommendUser",//选中状态
				mentionUserList:[],//用户列表
				mentionUserListPage:2,//翻页页码
				mentionUserListPageText:this.$t('clickToLoadMore'),
				mentionUserRolesList:[],//角色列表
				
				sensitive:[],//本地关键词列表
				
				commentPost:null,//评论帖子
				
				onKeyboardHeightChange:0,//软键盘高度
			}
		},
		onUnload() {},
		mounted() {},
		onLoad(e) {
			// #ifndef H5
			uni.onKeyboardHeightChange(res => {
			  this.onKeyboardHeightChange = res.height;
			})
			// #endif
			// 是否登录
			if(!this.$_isLogin()){
				uni.showToast({
					title: this.$t('errorNoLogin'),
					icon: 'none',
					duration: 1500
				});
				setTimeout(()=>{uni.switchTab({url:"/pages/my/my"})},1500);
				return
			}
			//路由传来的参数
			this.onLoadE = e;
			// 改变顶部导航的名字
			if(this.onLoadE.type === 'post'){
				if(this.onLoadE.editType === 'new'){
					uni.setNavigationBarTitle({title: '新建帖子'});
				}
				if(this.onLoadE.editType === 'edit' || this.onLoadE.editType === 'one'){
					uni.setNavigationBarTitle({title: '编辑帖子'});
				}
			}
			if(this.onLoadE.type === 'comment'){
				uni.setNavigationBarTitle({title: '评论'});
			}
			// 开始请求相关数据，保证this.onLoadE拿到了参数
			if(this.onLoadE){
				// 请求后端编辑器配置
				this.getEditorConfigs();
			}else{
				uni.showToast({
					title: this.$t('errorUnknown'),
					icon: 'none',
					duration: 1500
				});
			}
		},
		methods: {
			// 编辑器，更多按钮
			clickMoreButton(){
				uni.showActionSheet({
					itemList: ['插入渐变内容'],
					success: (res) => {
						if(res.tapIndex == 0){
							this.content += `<y-gradient>渐变内容</y-gradient>`
						}
					}
				});
			},
			// 插入隐藏内容
			clickHidePostButton(){
				this.content += `[hide]隐藏内容，不支持附件插入[/hide]`
			},
			// 输入框聚焦时触发
			textareaFocus(e){
				uni.getSelectedTextRange({
					success: (res) => {
						this.contentCursorStart = res.start;
						this.contentCursorEnd = res.end;
					}
				})
			},
			// 输入框失去焦点时触发
			textareaBlur(){},
			// 输入框行数变化时调用
			textareaLinechange(){},
			// 当键盘输入时，触发 input 事件
			textareaInput(){},
			// 请求后端编辑器配置
			getEditorConfigs(){
				this.$_request(
					"GET",`/api/fresns/v1/editor/${this.onLoadE.type}/configs`,{},
					(res) => {
						if(res.data.code === 0){
							this.editorConfigs = res.data.data;
							// 判断是否可以创建新草稿 这里有缓存问题暂时注释掉
							// if(!this.editorConfigs.publish.perm.draft){
							// 	uni.showToast({
							// 		title: this.$t('errorUnknown'),
							// 		icon: 'none',
							// 		duration: 1500
							// 	});
							// 	setTimeout(()=>{
							// 		uni.navigateBack();
							// 	},1500);
							// 	return
							// }
							// 如果开启了表情，请求原生表情列表
							if(this.editorConfigs.editor.sticker){
								this.getSticker();
							}
							// 请求编辑器配置信息.前端
							this.getEditorConfigsJSON();
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1500
							});
							setTimeout(()=>{
								uni.navigateBack();
							},1500);
						}
					}
				)
			},
			// 编辑器配置信息.前端
			getEditorConfigsJSON(){
				uni.request({
					url:this.$_configFile() + "editor.json",
					success: (res) => {
						this.editorConfigsJSON = res.data;
						// 是否开启了本地关键词检测
						if(res.data.sensitiveWordDetection){
							// 获取本地关键词列表
							this.getEditorSensitive();
						}
						// 新建草稿
						if(this.onLoadE.editType === 'new'){
							// 创建草稿方法
							this.postEditorDraft();
						}
						// 编辑草稿
						if(this.onLoadE.editType === 'edit'){
							this.draftDID = this.onLoadE.did;
							// 获取草稿详情
							this.getEditorDraft();
						}
						// 加载草稿列表的第一个草稿
						if(this.onLoadE.editType === 'one'){
							if(this.onLoadE.type === 'comment'){
								this.getCommentPost();
							}else{
								// 先获取草稿列表,在获取第一个草稿的DID然后读取草稿详情，如果没有草稿则新建草稿
								this.$_request(
									"GET","/api/fresns/v1/editor/post/drafts",
									{},
									(ref) => {
										if(ref.data.data.list.length){
											this.draftDID = ref.data.data.list[0].did;
											// 获取草稿详情
											this.getEditorDraft();
										}else{
											// 创建草稿方法
											this.postEditorDraft();
										}
									}
								)
							}
						}
					}
				})
			},
			// 获取本地关键词列表
			getEditorSensitive(){
				uni.request({
					url:this.$_configFile() + "sensitive.json",
					success: (res) => {
						this.sensitive = res.data;
					}
				})
			},
			// 获取帖子详情
			getCommentPost(){
				this.$_request(
					"GET",`/api/fresns/v1/post/${this.onLoadE.commentPid}/detail`,
					{
						"filterType":"whitelist",
						"filterKeys":"title,content"
					},
					(res) => {
						if(res.data.code === 0) {
							if(this.onLoadE.focus && this.onLoadE.focus == '1'){
								this.focus = true;
							}
							this.commentPost = res.data.data.detail;
							// 先获取草稿列表,在获取第一个草稿的DID然后读取草稿详情，如果没有草稿则新建草稿
							this.$_request(
								"GET","/api/fresns/v1/editor/comment/drafts",
								{},
								(ref) => {
									if(this.onLoadE.audio && this.onLoadE.audio == 1){
										this.audioBoxStatus = true;
									}
									if(this.onLoadE.emoji && this.onLoadE.emoji == 1){
										this.emojiStatus = true;
									}
									if(ref.data.data.list.length){
										if(this.onLoadE.commentPid == ref.data.data.list[0].replyToPid){
											this.draftDID = ref.data.data.list[0].did;
											// 获取草稿详情
											this.getEditorDraft();
										}else{
											this.$_request(
												"DELETE",`/api/fresns/v1/editor/comment/draft/${ref.data.data.list[0].did}`,{},
												(_ref) => {
													if(_ref.data.code == 0){
														// 创建草稿方法
														this.postEditorCommentDraft();
													}else{
														uni.showToast({
															title: _ref.data.message,
															duration: 1500
														});
													}
												}
											)
										}
									}else{
										// 创建草稿方法
										this.postEditorCommentDraft();
									}
								}
							)
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1500
							});
							setTimeout(()=>{
								uni.navigateBack();
							},1500);
						}
					}
				)
			},
			// 创建评论草稿
			postEditorCommentDraft(){
				this.$_request(
					"POST",`/api/fresns/v1/editor/comment/draft`,
					{
						"commentPid":this.onLoadE.commentPid,
					},
					(res) => {
						if(res.data.code === 0) {
							// 创建成功，获取草稿DID
							this.draftDID = res.data.data.detail.did;
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1500
							});
							setTimeout(()=>{
								uni.navigateBack();
							},1500);
						}
					}
				)
			},
			// 创建草稿
			postEditorDraft(){
				this.$_request(
					"POST",`/api/fresns/v1/editor/${this.onLoadE.type}/draft`,
					{},
					(res) => {
						if(res.data.code === 0) {
							// 创建成功，获取草稿DID
							this.draftDID = res.data.data.detail.did;
							
							// 以下是路由传参过来的自定义的东西
							
							// 光标获取焦点事件
							if(this.onLoadE.focus){
								if(this.onLoadE.focus == 1){
									this.focus = true;
								}
							}
							
							// ## anonymous
							// 参数：0 | 1
							// anonymous=0 默认不匿名
							// anonymous=1 默认匿名
							// 注意：一定要注意用户是否支持匿名如果不支持则无效
							// 例子：editor/editor?type=post&editType=new&anonymous=1
							if(this.onLoadE.anonymous){
								if(this.onLoadE.anonymous == 0){
									this.isAnonymous = false;
								}else{
									this.isAnonymous = true;
								}
							}
							// ## comment
							// 参数：1 | 2 | 3 | 4 | 5
							// 1 所有人
							// 2 你关注的人
							// 3 你关注的人和已认证的人
							// 4 不允许所有人 
							// 5 仅限你提及到的用户
							// 注意：一定要注意用户是否支持设置如果不支持则无效
							// 例子：editor/editor?type=post&editType=new&comment=1
							if(this.onLoadE.comment){
								if(this.onLoadE.comment == 1){this.commentPolicy = 1;}
								if(this.onLoadE.comment == 2){this.commentPolicy = 2;}
								if(this.onLoadE.comment == 3){this.commentPolicy = 3;}
								if(this.onLoadE.comment == 4){this.commentPolicy = 4;}
								if(this.onLoadE.comment == 5){this.commentPolicy = 5;}
							}
							// ## gid&gname
							// gid 小组id
							// gname 是小组名称
							// 必须同时存在，且保证后台开启了小组，且用户有权限发布
							if(this.onLoadE.gid&&this.onLoadE.gname){
								this.groupGid = this.onLoadE.gid;
								this.groupName = this.onLoadE.gname;
							}
							// ## content
							// 直接传内容，比如默认话题等等
							// editor/editor?type=post&editType=new&content=#生活打卡#
							if(this.onLoadE.content){
								this.content += this.onLoadE.content;
							}
							// ## image
							// 参数 1
							// 打开编辑器直接打开图片事件
							// 一定确保当前用户组有权限上传图片
							// 例子：editor/editor?type=post&editType=new&content=#生活打卡#&image=1
							if(this.onLoadE.image && this.onLoadE.image == 1){
								this.clickImageButton();
							}
							// ## video
							// 参数 1
							// 打开编辑器直接打开视频事件
							// 一定确保当前用户组有权限上传视频
							// 例子：editor/editor?type=post&editType=new&content=#生活打卡#&video=1
							if(this.onLoadE.video && this.onLoadE.video == 1){
								this.clickVideoButton();
							}
							
							// ## audio
							// 参数 1
							// 打开编辑器直接打开录音事件 一定确保当前用户组有权限上传音频 
							// 例子：editor/editor?type=post&editType=new&content=#生活打卡#&audio=1
							if(this.onLoadE.audio && this.onLoadE.audio == 1){
								this.audioBoxStatus = true;
							}
							
							// ## map
							// 参数 1
							// 打开编辑器直接打开选择位置事件
							// 一定确保当前用户组有权限选择位置
							// 例子：editor/editor?type=post&editType=new&content=#生活打卡#&map=1
							if(this.onLoadE.map && this.onLoadE.map == 1){
								this.cliclLocationInfoButton();
							}
						}else if(res.data.code === 38106){
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1500
							});
							setTimeout(()=>{
								uni.redirectTo({
									url:"/pages/draft/draft"
								})
							},1500);
						}else{
							uni.showToast({
								title: res.data.message,
								icon: 'none',
								duration: 1500
							});
							setTimeout(()=>{
								uni.navigateBack();
							},1500);
						}
					}
				)
			},
			// 更新草稿
			patchEditorDraft(type){
				// 是否开启了本地关键词检测
				if(this.editorConfigsJSON.sensitiveWordDetection){
					// = 1 是替换，否则提示
					if(this.editorConfigsJSON.sensitiveWordDetectionType == 1){
						this.sensitive.forEach(word => {
							let regex = new RegExp(word, 'gi');
							this.content = this.content.replace(regex, '***');
						});
					}else{
						let _key =  this.sensitive.some(word => this.content.includes(word));
						if(_key){
							uni.hideLoading();
							uni.showToast({
								title: this.$t('warningSensitive'),
								icon: 'error',
								duration: 1500
							});
							return;
						}
					}
				}
				// 自动替换话题
				if(this.onLoadE.type == 'post'){
					if(type == 'cliclSubmitButton' && this.editorConfigsJSON.replaceHashtagStatus){
						// 如果开启了自动替换
						if(this.editorConfigs.editor.hashtag.format == 1){
							this.content = this.$_matchReplaceHashtag(this.content,this.editorConfigsJSON.replaceHashtag,1)
						}else{
							this.content = this.$_matchReplaceHashtag(this.content,this.editorConfigsJSON.replaceHashtag,2)
						}
					}
				}
				// 这里判断，如果是回复编辑器，如果是有附件，如果内容为空则正文内容变成空
				if(this.onLoadE.type === 'comment'){
					if(!this.content){
						if(this.fileList.images.length||this.fileList.videos.length||this.fileList.audios.length||this.fileList.documents.length){
							this.content = "附件内容"
						}else{
							this.content = ""
						}
					}
				}
				this.$_request(
					"PATCH",`/api/fresns/v1/editor/${this.onLoadE.type}/draft/${this.draftDID}`,
					{
						"quotePid":this.quotePid,// 帖子专用: 引用的帖子 PID
						"gid":this.groupGid,// 帖子专用: 小组
						"title":this.title,// 帖子专用: 标题
						"content":this.content,// 正文内容
						"isMarkdown":this.isMarkdown,//内容是否为 MD 格式
						"isAnonymous":this.isAnonymous,//是否匿名
						"commentPolicy":this.commentPolicy,//Number	NO	谁可以评论
						"commentPrivate":"",//帖子使用 所有评论是否为私有
						"gtid":"",// 地理位置 ID
						"locationInfo":this.locationInfo.name == this.$t('editorLocation')?"":this.locationInfo,//地理位置信息
						"fileInfo":"",//文件信息
						"archives":"",//扩展参数
						"extends":"",//扩展内容
						"deleteLocation":"",//删除位置信息
						"deleteExtend":"",// 删除扩展内容，传参 eid
						"deleteFile":this.fileFID,// 删除文件，传参 fid
					},
					(res) => {
						uni.hideLoading();
						// 如果保存失败
						if(res.data.code != 0){
							uni.showToast({
								title: res.data.message,
								duration: 1500,
								icon:"none"
							});
							return
						}
						// 点击直接发布按钮事件
						if(type === 'cliclSubmitButton'){
							this.$_request(
								"POST",`/api/fresns/v1/editor/${this.onLoadE.type}/draft/${this.draftDID}`,{},
								(ref) => {
									if(ref.data.code === 0){
										// 发布成功
										// 这里的同步储存用于通知上一页的重新加载
										uni.setStorageSync('editorPublishSuccess', 'update');
										uni.navigateBack()
									}else if(ref.data.code === 38208){
										// 小组不存在，打开小组选择页面
										this.clickGroupButton();
									}else{
										uni.showToast({
											title: ref.data.message,
											icon: 'none',
											duration: 1500
										});
									}
								}
							)
						}
						// 点击，删除附件按钮事件
						if(type === 'clickFileButton'){
							// 文件 FID 初始化为空
							this.fileFID = "";
							// 获取草稿详情
							this.getEditorDraft();
						}
						// 点击，保存草稿按钮
						if(type === 'cliclSaveButton'){
							uni.showToast({
								icon:'success',
								duration: 1500
							});
						}
					}
				)
			},
			// 获取草稿详情
			getEditorDraft(){
				this.$_request(
					"GET",`/api/fresns/v1/editor/${this.onLoadE.type}/draft/${this.draftDID}`,{},
					(res) => {
						const d = res.data.data.detail;
						if(this.onLoadE.type === 'post'){
							// 引用帖子
							if(d.quotedPid){
								this.quotePid = d.quotedPid;
							}
							// 小组
							if(d.group){
								this.groupGid = d.group.gid;
								this.groupName = d.group.name;
							}
							// 标题
							if(d.title){
								this.title = d.title;
							}
							// 内容
							if(d.content){
								this.content = d.content;
							}
							// 内容是否为 MD 格式
							this.isMarkdown = d.isMarkdown;
							// 是否匿名
							this.isAnonymous = d.isAnonymous;
							// 谁可以评论
							this.commentPolicy = d.permissions.commentConfig.policy;
							// 位置信息
							if(d.locationInfo){
								this.locationInfo = d.locationInfo;
							}
							// 附件列表
							this.fileList = d.files;
						}
						if(this.onLoadE.type === 'comment'){
							// 内容
							if(d.content){
								this.content = d.content;
							}
							// 位置信息
							if(d.locationInfo){
								this.locationInfo = d.locationInfo;
							}
							// 附件列表
							this.fileList = d.files;
						}
					}
				)
			},
			// 请求表情
			getSticker(){
				this.$_request(
					"GET", "/api/fresns/v1/global/stickers", {},
					(res) => {
						this.emojiCategories = res.data.data;
					}
				)
			},
			// 左侧切换表情按钮
			clickSwitchEmojiButton(type, item) {
				this.emojiHover = type;
				if (type != 'emoji') {
					this.emojiNativeList = item.stickers;
				}
			},
			// 选中表情
			clickEmojiButton(e) {
				this.content += `${e}`;
				this.emojiStatus = false;
			},
			// 点击，直接发布按钮
			cliclSubmitButton(){
				uni.showLoading();
				this.patchEditorDraft('cliclSubmitButton');
			},
			// 点击，小组选择按钮
			clickGroupButton(){
				this.groupBoxStatus = true;
				this.$_request(
					"GET","/api/fresns/v1/group/tree",
					{
						"filterType":"whitelist",
						"filterKeys":"publishRule.canPublish,publishRule.allowPost,gid,name"
					},
					(res) => {
						this.groupList = res.data.data;
					}
				)
			},
			// 点击，选中小组
			clickSelectGroupButton(gid,name){
				this.groupGid = gid;
				this.groupName = name;
				this.groupBoxStatus = false;
			},
			// 点击，选中位置按钮
			cliclLocationInfoButton(){
				uni.chooseLocation({
					success: (res) => {
						this.locationInfo = {
							"langTag": "",
							"name": res.name,
							"mapId": 4,
							"latitude": res.latitude,
							"longitude": res.longitude
						}
					}
				});
			},
			// 点击，参与话题插入话题按钮
			clickInsertHashtagButton(item){
				// 话题格式 1.单 #
				if(this.editorConfigs.editor.hashtag.format == 1){
					this.content += `#${item}`;
					return;
				}
				// 话题格式 2.双 #
				if(this.editorConfigs.editor.hashtag.format == 2){
					this.content += `#${item}#`;
					return;
				}
			},
			// 点击，插入正文 # 
			clickInsertHashtagButton_2(){
				uni.showModal({
					title: '插入话题',
					confirmText: '插入',
					editable: true,
					success: (res) => {
						let c = res.content;
						if(res.confirm){
							// 话题格式 1.单 #
							if(this.editorConfigs.editor.hashtag.format == 1){
								this.content += `#${c}`;
								return;
							}
							// 话题格式 2.双 #
							if(this.editorConfigs.editor.hashtag.format == 2){
								this.content += `#${c}#`;
								return;
							}
						}
					}
				});
			},
			// 点击，图片按钮
			clickImageButton(){
				if(this.fileList){
					if(this.fileList.images.length >= this.editorConfigs.editor.image.maxUploadNumber){
						uni.showToast({
							title: '已经够数了哦',
							duration: 1000,
							icon:"none"
						});
					}else{
						uni.chooseImage({
							count: this.editorConfigs.editor.image.maxUploadNumber,
							sizeType:[this.editorConfigsJSON.sizeType],
							success: (res) => {
								this.clickImageButtonUpload(res.tempFiles)
							}
						})
					}
				}else{
					uni.chooseImage({
						count: this.editorConfigs.editor.image.maxUploadNumber,
						sizeType:[this.editorConfigsJSON.sizeType],
						success: (res) => {
							this.clickImageButtonUpload(res.tempFiles)
						}
					})
				}
			},
			// 上传图片
			clickImageButtonUpload(params){
				uni.showLoading();
				return new Promise((presolve, preject) => {
					let uploads = [];
					(params).forEach((item, i) => {
						uploads[i] = new Promise((resolve) => {
							uni.uploadFile({
								url: this.$_url() + "/api/fresns/v1/common/file/upload",
								filePath: item.path,
								name: "file",
								header: this.$_fresnsHeader(),
								formData:{
									"usageType":`${this.onLoadE.type}Draft`,
									"usageFsid":this.draftDID,
									"type":"image"
								},
								success(res) {
									if(JSON.parse(res.data).code == 0){
										resolve()
									}else{
										uni.hideLoading();
										uni.showToast({
											title: JSON.parse(res.data).message,
											icon: 'none',
											duration: 1000
										});
										setTimeout(()=>{
											resolve()
										},1000);
									}
								},
								fail(err) {
									
								}
							})
						})
					})
					Promise.all(uploads).then(res => {
						//图片上传完成
						presolve(res)
						uni.hideLoading();
						// 获取草稿详情
						this.getEditorDraft();
					}).catch(err => {
						preject(err)
						uni.showToast({
							title: '上传失败请重试',
							icon: 'none'
						})
					})
				})
			},
			// 点击，删除附件按钮
			clickFileButton(fid){
				//fileFID
				uni.showModal({
					title: this.$t('tip'),
					content: `${this.$t('deleteThisFile')} ?`,
					success: (res) => {
						if(res.confirm){
							this.fileFID = fid;
							// 更新草稿
							this.patchEditorDraft('clickFileButton');
						}else{
							this.fileFID = "";
						}
					}
				});
			},
			// 点击，插入附件到正文 
			clickInsertFileButton(fid){
				this.content += `[file:${fid}]`;
			},
			// 点击，视频按钮
			clickVideoButton(){
				if(this.fileList){
					if(this.fileList.videos.length >= this.editorConfigs.editor.video.maxUploadNumber){
						uni.showToast({
							title: '已经够数了哦',
							duration: 1000,
							icon:"none"
						});
					}else{
						uni.chooseVideo({
							maxDuration:60,
							compressed:this.editorConfigsJSON.compressed,
							success: (res) => {
								this.clickVideoButtonUpload(res.tempFilePath)
							}
						})
					}
				}else{
					uni.chooseVideo({
						maxDuration:60,
						compressed:this.editorConfigsJSON.compressed,
						success: (res) => {
							this.clickVideoButtonUpload(res.tempFilePath)
						}
					})
				}
			},
			// 上传视频
			clickVideoButtonUpload(video){
				const _this = this;
				uni.showLoading();
				uni.uploadFile({
					url: _this.$_url() + "/api/fresns/v1/common/file/upload",
					filePath: video,
					name: "file",
					header: _this.$_fresnsHeader(),
					formData:{
						"usageType":`${this.onLoadE.type}Draft`,
						"usageFsid":this.draftDID,
						"type":"video"
					},
					success(res) {
						uni.hideLoading();
						if(JSON.parse(res.data).code == 0){
							_this.getEditorDraft();
							uni.hideLoading();
						}else{
							uni.showToast({
								title: JSON.parse(res.data).message,
								icon: "none",
								duration: 1000
							});
						}
					}
				})
			},
			// 点击，开始录音
			clickAudioButton(){
				this.audioStartStatus = !this.audioStartStatus;
				if(this.audioStartStatus){
					this.audioButtonText = "录制中，单击停止录制"
					uni.getRecorderManager().start();
					this.timer = setInterval(() => {
						this.audioDuration += 1;
						if(this.audioDuration == this.editorConfigs.editor.audio.maxDuration){
							this.audioButtonText = "单击开始录制音频";
							this.audioStartStatus = false;
							clearInterval(this.timer)
							uni.getRecorderManager().stop();
							uni.getRecorderManager().onStop((res) => {
								this.clickAudioButtonUpload(res.tempFilePath)
							});
						}
					}, 1000);
				}else{
					this.audioButtonText = "单击开始录制音频";
					this.audioStartStatus = false;
					clearInterval(this.timer)
					uni.getRecorderManager().stop();
					uni.getRecorderManager().onStop((res) => {
						this.clickAudioButtonUpload(res.tempFilePath)
					});
				}
			},
			// 上传音频
			clickAudioButtonUpload(audio){
				this.audioDuration = 0;
				this.audioBoxStatus = false;
				const _this = this;
				uni.showLoading();
				uni.uploadFile({
					url: _this.$_url() + "/api/fresns/v1/common/file/upload",
					filePath: audio,
					name: "file",
					header: _this.$_fresnsHeader(),
					formData:{
						"usageType":`${this.onLoadE.type}Draft`,
						"usageFsid":this.draftDID,
						"type":"audio"
					},
					success(res) {
						uni.hideLoading();
						if(JSON.parse(res.data).code == 0){
							_this.getEditorDraft();
							uni.hideLoading();
						}else{
							uni.showToast({
								title: JSON.parse(res.data).message,
								icon: "none",
								duration: 1000
							});
						}
					}
				})
			},
			// 点击艾特按钮
			clickMentionBoxButton(){
				this.mentionStatus = true;
				this.$_request(
					"GET","/api/fresns/v1/global/roles",
					{
						"status":1
					},
					(res) => {
						this.mentionUserRolesList = res.data.data.list;
					}
				)
				
			},
			// 选中用户
			clickMentionUserButton(user){
				this.content += `@${user}`;
				this.mentionStatus = false;
			},
			// 点击，切换卡
			clickMentionTabButton(type){
				this.mentionUserListPage = 2;
				this.mentionUserListPageText = this.$t('clickToLoadMore');
				this.mentionListHover = type;
				const uid = JSON.parse(uni.getStorageSync('accountAuthToken')).uid;
				if(type === 'RecommendUser'){
					
				}else if(type === 'myFollowers'){
					this.$_request(
						"GET",`/api/fresns/v1/user/${uid}/interaction/followers`,
						{
							"filterType":"whitelist",
							"filterKeys":"uid,username,nickname,avatar,roleName",
						},
						(res) => {
							this.mentionUserList = res.data.data.list;
						}
					)
				}else{
					this.$_request(
						"GET","/api/fresns/v1/user/list",
						{
							"roles":type,
							"filterType":"whitelist",
							"filterKeys":"uid,username,nickname,avatar,roleName",
						},
						(res) => {
							this.mentionUserList = res.data.data.list;
						}
					)
				}
			},
			// 点击，艾特用户列表翻页
			clickMentionUserListMore(type){
				const uid = JSON.parse(uni.getStorageSync('accountAuthToken')).uid;
				
				if(type == 'myFollowers'){
					if (this.mentionUserListPageText == this.$t('loading')) { return }
					this.mentionUserListPageText = this.$t('loading');
					this.$_request(
						"GET",`/api/fresns/v1/user/${uid}/interaction/followers`,
						{
							"filterType":"whitelist",
							"filterKeys":"uid,username,nickname,avatar,roleName",
							"page":this.mentionUserListPage
						},
						(res) => {
							if (res.data.data.list.length) {
								this.mentionUserList = this.mentionUserList.concat(res.data.data.list);
								this.mentionUserListPage++
								this.mentionUserListPageText = this.$t('clickToLoadMore')
							} else {
								this.mentionUserListPageText = this.$t('listEmpty')
							}
						}
					)
				}else{
					this.$_request(
						"GET","/api/fresns/v1/user/list",
						{
							"roles":type,
							"filterType":"whitelist",
							"filterKeys":"uid,username,nickname,avatar,roleName",
							"page":this.mentionUserListPage
						},
						(res) => {
							if (res.data.data.list.length) {
								this.mentionUserList = this.mentionUserList.concat(res.data.data.list);
								this.mentionUserListPage++
								this.mentionUserListPageText = this.$t('clickToLoadMore')
							} else {
								this.mentionUserListPageText = this.$t('listEmpty')
							}
						}
					)
				}
			},
			// 点击，保存草稿按钮
			cliclSaveButton(){
				uni.showLoading();
				this.patchEditorDraft('cliclSaveButton');
			},
			// 点击所有人可评论按钮
			clickCommentPolicyButton(){
				uni.showActionSheet({
					itemList: [
						'所有人',
						'你关注的人',
						'你关注的人和已认证的人',
						'不允许所有人',
						'仅限你提及到的用户'
					],
					success: (res) => {
						if(res.tapIndex == 0){this.commentPolicy = 1;}
						if(res.tapIndex == 1){this.commentPolicy = 2;}
						if(res.tapIndex == 2){this.commentPolicy = 3;}
						if(res.tapIndex == 3){this.commentPolicy = 4;}
						if(res.tapIndex == 4){this.commentPolicy = 5;}
					}
				});
			},
			// 点击引用帖子
			clickQuoteBoxStatusButton(){
				this.quoteBoxStatus = true;
				if(this.quoteBoxStatus){
					const userUid = JSON.parse(uni.getStorageSync('accountAuthToken')).uid;
					this.$_request(
						"GET", `/api/fresns/v1/user/${userUid}/mark/follow/posts`,
						{
							"filterType":"whitelist",
							"filterKeys":"pid,author.avatar,author.nickname,createdTimeAgo,title,content",
							"page":1
						},
						(res) => {
							if (res.data.data.list.length) {
								this.quoteList = res.data.data.list;
								this.quoteListStatus = "success";
							} else {
								this.quoteListStatus = "empty";
							}
						}
					)
				}
			},
			// 选中引用的帖子
			clickSelectQuotePostButton(item){
				this.quotePid = item.pid;
				this.quoteContent = item.title?item.title:this.$_filterHtml(item.content);
				this.quoteBoxStatus = false;
			},
			clickQuotePostMoreButton(){
				if (this.quoteListPageText == this.$t('loading')) { return }
				this.quoteListPageText = this.$t('loading');
				const userUid = JSON.parse(uni.getStorageSync('accountAuthToken')).uid;
				this.$_request(
					"GET", `/api/fresns/v1/user/${userUid}/mark/follow/posts`,
					{
						"filterType":"whitelist",
						"filterKeys":"pid,author.avatar,author.nickname,createdTimeAgo,title,content",
						"page": this.quoteListPage
					},
					(res) => {
						if (res.data.data.list.length) {
							this.quoteList = this.quoteList.concat(res.data.data.list);
							this.quoteListPage++
							this.quoteListPageText = this.$t('clickToLoadMore')
						} else {
							this.quoteListPageText = this.$t('listEmpty')
						}
					}
				)
			},
		},
		onBackPress(e){
			if(e.from == 'backbutton'){
				// 如果小组选择框子在，先设置为不显示
				if(
					this.groupBoxStatus || 
					this.emojiStatus || 
					this.audioBoxStatus || 
					this.mentionStatus
				)
				{
					this.groupBoxStatus = false;
					this.emojiStatus = false;
					this.audioBoxStatus = false;
					this.mentionStatus = false;
					return true; // 禁止返回
				}else{
					clearInterval(this.timer)
					return false; // 可以返回
				}
			}
			// 如果是uni.navigateBack()事件，则直接返回，通常都是发布成功以后调用
			if(e.from == 'navigateBack'){
				clearInterval(this.timer)
				return false;
			}
		},
	}
</script>

<style lang="scss">
.editor{
	.title-box{
		background: #FFF;
		margin: 25rpx 25rpx 0 25rpx;
		display: flex;
		align-items: center;
		input{
			flex: 1;
			font-size: 32rpx;
			padding: 25rpx;
			line-height: 32rpx;
		}
		text{
			flex-shrink: 0;
			padding-right: 25rpx;
			font-size: 22rpx;
			color: $placeholder;
		}
	}
	.comment-post-box{
		background: #FFF;
		margin: 25rpx 25rpx 0 25rpx;
		display: flex;
		align-items: center;
		padding: 25rpx;
		.comment-post-box-left{
			flex-shrink: 0;
			color: $placeholder;
		}
		.comment-post-box-right{
			flex: 1;
			display: -webkit-box;
			-webkit-box-orient: vertical;
			-webkit-line-clamp: 2;
			overflow: hidden;
		}
	}
	.content-box{
		background: #FFF;
		margin: 25rpx 25rpx 0 25rpx;
		textarea{
			width:calc(100% - 50rpx);
			font-size: 32rpx;
			padding: 25rpx;
			min-height: 200rpx;
		}
		.content-box-other{
			display: flex;
			align-items: center;
			justify-content:space-between;
			padding: 0 25rpx 25rpx 25rpx;
			.content-box-other-left{
				display: flex;
				align-items: center;
				view{
					display: flex;
					align-items: center;
					line-height: 22rpx;
					margin-right: 25rpx;
					text{
						font-size: 22rpx;
						color: $placeholder;
					}
					.iconfont{
						padding-left: 5rpx;
					}
				}
			}
			.content-box-other-right{
				display: flex;
				align-items: center;
				font-size: 22rpx;
				text{
					line-height: 22rpx;
					color: $placeholder;
				}
			}
		}
	}
	.operating-button-other{
		margin: 0 25rpx;
		background: #FFF;
		display: flex;
		align-items: center;
		padding: 25rpx;
		border-top: 1px solid $background;
		view{
			display: flex;
			align-items: center;
			line-height: 22rpx;
			background: $background;
			padding: 10rpx 15rpx;
			flex-shrink: 0;
			
			text{
				font-size: 22rpx;
			}
			.iconfont{
				padding-right: 5rpx;
			}
		}
	}
	.operating-button-hashtag{
		display: flex;
		align-items: center;
		background: #FFF;
		border-top: 1px solid $background;
		margin: 0 25rpx;
		height: 80rpx;
		._text{
			display: flex;
			align-items: center;
			justify-content: center;
			height: 80rpx;
			padding-left: 25rpx;
			.icon-arrow-right-filling{
				font-size: 22rpx;
				padding-left: 5rpx;
			}
		}
		scroll-view{
			flex: 1;
			height: 80rpx;
			white-space: nowrap;
			margin: 0 10rpx 0 20rpx;
			.operating-button-hashtag-for{
				display: inline-flex;
				height: 80rpx;
				align-items: center;
				view{
					line-height: 22rpx;
					font-size: 22rpx;
					background: $background;
					color: $placeholder;
					padding: 10rpx;
					margin-right: 25rpx;
				}
			}
		}
	}
	.editor-tool-button{
		display: flex;
		align-items: center;
		margin: 0 25rpx;
		background: #FFF;
		border-top: 1px solid $border;
		justify-content: center;
		.editor-tool-button-for{
			line-height: 50rpx;
			padding: 25rpx 12.5rpx;
			text{
				font-size: 50rpx;
			}
		}
	}
	.quote-post{
		display: flex;
		align-items: center;
		background: #FFF;
		margin: 25rpx;
		margin-bottom: 0;
		padding: 25rpx;
		.icon-yinyong1{
			color: $placeholder;
		}
		.icon-close-bold{
			color: $red;
		}
	}
	.editor-file{
		display: flex;
		flex-wrap: wrap;
		.editor-file-for{
			width: 213rpx;
			height: 213rpx;
			overflow: hidden;
			position: relative;
			margin: 25rpx 0 0 25rpx;
			border: 1px solid $border;
			background: #FFF;
			.icon-close-bold{
				display: flex;
				align-items: center;
				justify-content: center;
				width: 40rpx;
				height: 40rpx;
				background: $red;
				color: #FFF;
				line-height: 22rpx;
				font-size: 22rpx;
				position: absolute;
				top: 10rpx;
				right: 10rpx;
				z-index: 2;
				border-radius: 100rpx;
			}
			.editor-file-for-content{
				width: 213rpx;
				height: 213rpx;
				overflow: hidden;
				position: absolute;
				top: 0;
				left: 0;
				z-index: 1;
				image{
					display: block;
					width: 100%;
				}
				.icon-play{
					width: 213rpx;
					height: 213rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					background: #000;
					color: #FFF;
					font-size: 80rpx;
					line-height: 80rpx;
				}
			}
			.editor-file-for-text{
				width: 100%;
				height: 50rpx;
				color: #FFF;
				background-color:rgba(0,0,0,0.5);
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 22rpx;
				line-height: 22rpx;
				position: absolute;
				left: 0;
				bottom: 0;
				z-index: 2;
			}
		}
		.editor-file-for-audio{
			width: 700rpx;
			height: 58rpx;
			margin: 25rpx 25rpx 0 25rpx;
			display: flex;
			align-items: center;
			// .editor-file-for-text{
			// 	width: 150rpx;
			// 	height: 58rpx;
			// 	background: $theme;
			// 	color: #FFF;
			// 	font-size: 22rpx;
			// 	line-height: 22rpx;
			// 	display: flex;
			// 	align-items: center;
			// 	justify-content: center;
			// }
			.icon-close-bold{
				width: 58rpx;
				height: 58rpx;
				background: $red;
				color: #FFF;
				font-size: 28rpx;
				line-height: 28rpx;
				display: flex;
				align-items: center;
				justify-content: center;
				border-radius: 0 10rpx 10rpx 0;
			}
		}
	}
	.publish-draft-button{
		display: flex;
		align-items: center;
		justify-content: center;
		background: #FFF;
		margin: 25rpx;
		padding: 25rpx;
		view{
			height: 80rpx;
			line-height: 28rpx;
			font-size: 28rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			flex: 1;
			color: #FFF;
		}
		view:nth-child(1){
			border-radius: 10rpx 0 0 10rpx;
		}
		view:nth-child(2){
			border-radius: 0 10rpx 10rpx 0;
		}
	}
}
// 弹窗，内容小组
.global-bottom-to-top-pop-up-groyp{
	max-height: 1000rpx;
	scroll-view{
		width: 100%;
		max-height: 1000rpx;
		.editor-right-group-list{
			padding-bottom: 25rpx;
			._for{
				display: flex;
				align-items: center;
				line-height: 32rpx;
				padding: 25rpx 25rpx 0 25rpx;
				text{
					font-size: 32rpx;
				}
				._symbol{
					display: block;
					width: 15rpx;
					height: 15rpx;
					background: #DDD;
					margin-right: 15rpx;
					border-radius: 100rpx;
				}
				._symbol-h{
					background: $theme;
				}
				._name-h{
					color: $theme;
				}
			}
			._pointer{
				cursor:pointer;
			}
		}
	}
}
// 引用帖子
.global-bottom-to-top-pop-up-quote-post{
	padding: 0 25rpx;
	scroll-view{
		width: 100%;
		max-height: 800rpx;
		white-space: nowrap;
		._quote-post-for-more{
			display: flex;
			align-items: center;
			justify-content: center;
			color: $placeholder;
			font-size: 22rpx;
			padding: 25rpx 0;
		}
		.global-bottom-to-top-pop-up-quote-post-empty{
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 22rpx;
			line-height: 22rpx;
			color: $placeholder;
			padding: 25rpx 0;
		}
		._quote-post-for{
			display: flex;
			align-items: center;
			padding: 25rpx 0;
			border-bottom: 1px dotted $border;
			._quote-post-for-avatar{
				flex-shrink: 0;
				width: 90rpx;
				height: 90rpx;
				overflow: hidden;
				border-radius: 100rpx;
			}
			._quote-post-for-right{
				flex: 1;
				padding-left: 15rpx;
				._quote-post-for-right-top{
					display: flex;
					align-items: center;
					line-height: 28rpx;
					text{
						font-size: 28rpx;
						padding-right: 15rpx;
						color: $placeholder;
					}
				}
				._quote-post-for-right-bottom{
					padding-top: 10rpx;
					text{
						display: -webkit-box;
						-webkit-box-orient: vertical;
						-webkit-line-clamp: 1;
						overflow: hidden;
					}
				}
			}
		}
	}
}
// 弹窗 表情
.select-emoji-box {
	display: flex;
	._box-left {
		width: 150rpx;
		max-height: 800rpx;
		background: $border;
		flex-shrink: 0;
		scroll-view {
			width: 150rpx;
			max-height: 800rpx;
			white-space: nowrap;
			view {
				font-size: 28rpx;
				line-height: 28rpx;
				padding: 25rpx;
			}
			._hover {
				background: #FFF;
				color: $theme;
			}
		}
	}
	._box-right {
		flex: 1;
		max-height: 800rpx;
		scroll-view {
			width: 100%;
			max-height: 800rpx;
			white-space: nowrap;
			display: flex;
			._emoji {
				display: flex;
				flex-wrap: wrap;
				padding: 25rpx;
				._emoji-for {
					padding: 12.5rpx;
					text {
						display: flex;
						align-items: center;
						justify-content: center;
						font-size: 50rpx;
						line-height: 50rpx;
					}
					view {
						width: 65rpx;
						height: 65rpx;
						overflow: hidden;
					}
				}
			}
		}
	}
}
// 音频录制
.global-bottom-to-top-pop-up-audio{
	.global-bottom-to-top-pop-up-audio-box{
		padding: 50rpx 0;
		._duration{
			line-height: 66rpx;
			height: 66rpx;
			text-align: center;
			text:nth-child(1){
				font-size: 66rpx;
			}
			text:nth-child(2){
				font-size: 32rpx;
				padding-left: 10rpx;
			}
		}
		._audio-button{
			border: 1px solid $border;
			background: #FFF;
			margin: 25rpx 25rpx 0 25rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			color: $placeholder;
			font-size: 28rpx;
			line-height: 28rpx;
			padding: 25rpx 0;
			border-radius: 100rpx;
			background: $background;
		}
	}
}
// 艾特他人
.global-bottom-to-top-pop-up-aite{
	max-height: 1000rpx;
	display: flex;
	.global-bottom-to-top-pop-up-aite-left{
		flex-shrink: 0;
		border-right: 1px solid $border;
		scroll-view{
			max-height: 1000rpx;
			view{
				font-size: 28rpx;
				line-height: 28rpx;
				border-bottom: 1px solid $border;
				padding: 25rpx;
				background: $background;
			}
			._hover{
				color: $theme;
				background: #FFF;
			}
		}
	}
	.global-bottom-to-top-pop-up-aite-right{
		flex: 1;
		scroll-view{
			max-height: 1000rpx;
			._user-for{
				display: flex;
				align-items: center;
				padding:25rpx 0;
				margin: 0 25rpx;
				border-bottom: 1px dashed $border;
				._user-for-avatar{
					width: 60rpx;
					height: 60rpx;
					overflow: hidden;
					border-radius: 100rpx;
				}
				._user-for-nickname{
					font-size: 28rpx;
					line-height: 28rpx;
					padding-left: 10rpx;
				}
				._user-for-roleName{
					font-size: 22rpx;
					line-height: 22rpx;
					color: $placeholder;
					padding-left: 10rpx;
				}
				._user-for-aite{
					font-size: 22rpx;
					line-height: 22rpx;
					color: $placeholder;
					margin-left: auto;
				}
			}
			._user-for-more{
				display: flex;
				align-items: center;
				justify-content: center;
				font-size: 22rpx;
				line-height: 22rpx;
				color: $placeholder;
				padding: 25rpx 0;
			}
		}
	}
}
</style>